package com.mnkjxy.beauty.view.manager;

import java.util.Observable;
import java.util.Observer;

import android.app.Activity;
import android.widget.RelativeLayout;

import com.mnkjxy.beauty.R;
import com.mnkjxy.beauty.values.Views;

public class TitleManage implements Observer {

	private static TitleManage instance;

	/**
	 * 通用的顶部标题栏
	 */
	private RelativeLayout common_container;

	/**
	 * 第二种顶部标题,测试用
	 */
	private RelativeLayout test_container;

	public static TitleManage geiInstance() {
		if (instance == null) {
			instance = new TitleManage();
		}
		return instance;
	}

	/**
	 * 
	 * @param activity
	 */
	public void init(Activity activity) {
		common_container = (RelativeLayout) activity
				.findViewById(R.id.title_container_common);
		test_container = (RelativeLayout) activity
				.findViewById(R.id.title_container_);

		setListener();
	}

	private void setListener() {

	}

	/**
	 * 显示通用的标题栏
	 */
	public void showCommonContainer() {
		hideAll();
		common_container.setVisibility(RelativeLayout.VISIBLE);
	}

	/**
	 * 显示测试用导航
	 */
	public void showTestContainer() {
		hideAll();
		test_container.setVisibility(RelativeLayout.VISIBLE);
	}

	/**
	 * 隐藏所有标题导航
	 */
	public void hideAll() {
		common_container.setVisibility(RelativeLayout.GONE);
		test_container.setVisibility(RelativeLayout.GONE);
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		int ViewID = Integer.parseInt(arg1.toString());
		switch (ViewID) {
		case Views.VIEW_FIRST_VIEW:
			showCommonContainer();
			break;
		case Views.VIEW_COURSE_VIEW:
			showTestContainer();
			break;
		default:
			break;
		}

	}
}
